import request from '../api/';

var plugins = {};
for (var i = 0; i < request.length; i++) {
  if (typeof request[i] === 'object' && request[i].list && Array.isArray(request[i].list)) {
    for (var j = 0; j < request[i].list.length; j++) {
      plugins['api_' + request[i].module + '_' + request[i].list[j].method] = (function (n, m) {
        return function ({ type = request[n].list[m].type, path = request[n].list[m].path, data, fn, errFn, headers, opts } = {}) {
          request[n].list[m].excute({ data, fn, errFn });
        };
      })(i, j);
    }
  }
}

export default plugins;